package com.ss.android.crash.log;

import android.app.ActivityManager;
import android.app.Application;
import android.content.Context;
import android.os.Build;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public final class f {
    private final Application.ActivityLifecycleCallbacks h;
    List a;
    List b;
    String c;
    String d;
    a e;
    private Application f;
    private Context g;
    f(Context arg3, a arg4) {

        this.a = new ArrayList();
        this.b = new ArrayList();
        this.h = new g(this);
        this.f = (Application) arg3.getApplicationContext();
        this.g = arg3.getApplicationContext();
        this.e = arg4;
        if (Build.VERSION.SDK_INT >= 14) {
            this.f.registerActivityLifecycleCallbacks(this.h);
        }
    }

    public final String a() {
        String v0_2;
        if (this.a != null && !this.a.isEmpty()) {
            try {
                StringBuilder v2 = new StringBuilder();
                Iterator v3 = this.a.iterator();
                int v1;
                for (v1 = 0; v3.hasNext(); ++v1) {
                    Object v0_1 = v3.next();
                    if (v1 < this.a.size() - 1) {
                        v2.append(((String) v0_1)).append("|");
                    } else {
                        v2.append(((String) v0_1));
                    }
                }

                v0_2 = v2.toString();
            } catch (Throwable v0) {
                v0_2 = "";
            }
        } else {
            v0_2 = "";
        }

        return v0_2;
    }

    public final String b() {
        Object v0_3;
        if (this.g == null) {
            String v0 = "";
            return v0;
        }

        try {
            List v0_2 = ((ActivityManager) this.g.getSystemService(Context.ACTIVITY_SERVICE)).getRunningTasks(5);
            if (v0_2 == null) {
                return "";
            }

            String v1 = this.g.getPackageName();
            StringBuilder v2 = new StringBuilder();
            Iterator v3 = v0_2.iterator();
            do {
                label_17:
                if (!v3.hasNext()) {
                    return "";
                }

                v0_3 = v3.next();
                if (v0_3 == null) {
                    continue;
                }

                if (((ActivityManager.RunningTaskInfo) v0_3).baseActivity == null) {
                    continue;
                }
            } while (!v1.equals(((ActivityManager.RunningTaskInfo) v0_3).baseActivity.getPackageName()));

            v2.append("id = ").append(((ActivityManager.RunningTaskInfo) v0_3).id).append(" ");
            v2.append("description = ").append(((ActivityManager.RunningTaskInfo) v0_3).description).append(" ");
            v2.append("number_of_activities = ").append(((ActivityManager.RunningTaskInfo) v0_3).numActivities).append(" ");
            v2.append("number_of_running_activities = ").append(((ActivityManager.RunningTaskInfo) v0_3).numRunning).append(" ");
            v2.append("topActivity = ").append(((ActivityManager.RunningTaskInfo) v0_3).topActivity.toString()).append(" ");
            v2.append("baseActivity = ").append(((ActivityManager.RunningTaskInfo) v0_3).baseActivity.toString());
            return v2.toString();
        } catch (Throwable v0_1) {
        }

        return "";
    }

    public interface a {
        void a();
    }
}

